#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

void mn_mencpy(void* dst, const void* src, size_t n)
{
	void* ret = dst;
	assert(dst && src);
	while (n--)
	{
		
		*((char*)src) = *((char*)dst);
		((char*)src)++;
		((char*)dst)++;

	}
	return ret;
}

void mn_memmove(void* dst, const void* src, size_t n)
{
	assert(dst && src);
	void* ret = dst;
	if (dst >= src && (char*)dst <= (char*)src + n)
	{
		char* cur1 = (char*)dst + n - 1;
		char* cur2 = (char*)src + n - 1;
		while (n--)
		{
			*cur1++ = *cur2++;
			
		}
	}
	else
	{
		while (n--)
		{

			*((char*)src) = *((char*)dst);
			((char*)src)++;
			((char*)dst)++;

		}
	}
	return ret;
}

char* mn_strstr(const char* dst, const char* src)
{
	char* cur1 = dst;
	
	char* p1 ,*p2;
	size_t n1 = strlen(dst) - strlen(src) + 1;
	size_t n2 = strlen(src);
	int flag = 0;
	assert(dst && src);
	while (n1--)
	{
		p1 = cur1;
		p2 = src;
		while (n2--)
		{
			if (*p1 - *p2)
			{
				flag = 1;
				break;
			}
			p1++;
			p2++;
		}
		if (flag == 0)
		{
			break;
			return cur1;
		}
		cur1++;
		
	}
	return NULL;
}